﻿using Microsoft.AspNetCore.Mvc;
using MyDapperApi.Models;
using MyDapperApi.Services;
using QYWXUpdate.DataModel;
using QYWXUpdate.DataModel.CheckInfo;

namespace MyDapperApi.Controllers;
/// <summary>
/// 【管理推送在线客流用户接口】
/// </summary>
[ApiController]
[Route("api/[controller]")]
public class CheckInfoRoleController : ControllerBase
{
    private readonly IAutoNetUpdateService _autoNetUpdateService;

    public CheckInfoRoleController(IAutoNetUpdateService autoNetUpdateService)
    {
        _autoNetUpdateService = autoNetUpdateService;
    }
    /// <summary>
    /// 分页获取需要更新的人员
    /// </summary>
    /// <param name="request"></param>
    /// <returns></returns>
    [HttpGet("Paging")]
    public async Task<IActionResult> Paging([FromQuery] CheckInfoRolePagingRequest request)
    {
        var users = await _autoNetUpdateService.PagingUpdateRole(request);
        return Ok(users);
    }
    /// <summary>
    /// 获取需要推送更新人员的详细信息
    /// </summary>
    /// <param name="request"></param>
    /// <returns></returns>
    [HttpGet("Get")]
    public async Task<IActionResult> Get([FromQuery] IdRequest request)
    {
        var users = await _autoNetUpdateService.GetUpdateRole(request);
        return Ok(users);
    }
    /// <summary>
    /// 保存需要推送更新人员的信息
    /// </summary>
    /// <param name="request"></param>
    /// <returns></returns>
    [HttpPost("Save")]
    public async Task<IActionResult> Save([FromBody] SaveCheckInfoRoleRequest request)
    {
        var users = await _autoNetUpdateService.SaveUpdateRole(request);
        return Ok(users);
    }
    /// <summary>
    /// 删除需要推送更新人员的信息
    /// </summary>
    /// <param name="request"></param>
    /// <returns></returns>
    [HttpGet("Delete")]
    public async Task<IActionResult> Delete([FromQuery] IdRequest request)
    {
        var users = await _autoNetUpdateService.DeleteUpdateRole(request);
        return Ok(users);
    }
}